package com.jin.crud.common.utils;

/**
 * @Author yuxuejin
 * @Date 2021/11/10 13:47
 * @Description:
 */
public class IdUtils {

    /**
     * 产生随机长度的数字
     *
     * @param length
     * @return
     */
    public static String generateCode(int length) {
        String str = String.valueOf(Math.random());
        if (length > 10) {
            length = 10;
        }
        // 递归保证密码符合长度
        if (str.length() < length + 2) {
            return generateCode(length);
        }

        str = str.substring(2, length + 2);
        return str;
    }

    public static String getId() {
        return generateCode(8);
    }


}
